package com.ludomancy.gamelib;

import java.awt.Point;

public class WorldScreenProjection
{
	public float screenWidth, screenHeight;
	public float worldWidth, worldHeight;
	
	public WorldScreenProjection(int screenWidth, int screenHeight, float worldWidth, float worldHeight)
	{
		this.screenWidth = screenWidth;
		this.screenHeight = screenHeight;
		this.worldWidth = worldWidth;
		this.worldHeight = worldHeight;
	}
	
	public Point screenToWorld(Point screenPos)
	{
		return new Point((int)(screenPos.x*worldWidth / screenWidth), (int) (screenPos.y*worldHeight / screenHeight));
	}
	
	public float screenToWorldX(int x)
	{
		return (float)x*worldWidth / screenWidth;
	}

	public float screenToWorldY(int y)
	{
		return (float)y*worldHeight / screenHeight;
	}
	
	public Point worldToScreen(Point pos)
	{
		return new Point((int)((pos.x*screenWidth)/worldWidth), (int)((pos.y*screenHeight)/worldHeight));
	}
	
	public int[] worldToScreen(float x, float y)
	{
		int[] ret = new int[2];
		ret[0] = (int)((x*screenWidth)/worldWidth); 
		ret[1] = (int)((y*screenHeight)/worldHeight);
		return ret;
	}

	public int worldToScreenX(float x)
	{
		return (int)((x*screenWidth)/worldWidth); 
	}
	
	public int worldToScreenY(float y)
	{
		return (int)((y*screenHeight)/worldHeight); 
	}
}
